package org.sbbs.app.security.webapp.action;

import org.sbbs.app.security.model.UrlSecurityResource;
import org.sbbs.app.security.service.UrlSecurityResourceManager;
import org.sbbs.base.pager.IPager;
import org.sbbs.base.pager.impl.JqgridPagerImpl;
import org.sbbs.base.searcher.SearchFilter;
import org.sbbs.base.searcher.SearchFilterBuilder;
import org.sbbs.base.webapp.action.BaseJqgridPagedAction;

public class UrlSecurityResourcePagedAction extends BaseJqgridPagedAction {
	/**
     *
     */
    private static final long serialVersionUID = -4720115820370561960L;

    @Override
	public Class getSearchEntityClazz() {
		return UrlSecurityResource.class;
	}

	@Override
	public int getSearchFilterType() {
		return SearchFilterBuilder.PROPERTY_FILTER;
	}

    private UrlSecurityResourceManager urlSecurityResourceManager;

    public UrlSecurityResourceManager getUrlSecurityResourceManager() {
        return urlSecurityResourceManager;
    }

    public void setUrlSecurityResourceManager( UrlSecurityResourceManager urlSecurityResourceManager ) {
        this.urlSecurityResourceManager = urlSecurityResourceManager;
    }

    @Override
    public String gridPageList() {
        try {
            IPager pager = new JqgridPagerImpl( getRequest() );
            SearchFilter sf = SearchFilterBuilder.buildSearchFilter( getRequest(), SearchFilterBuilder.JQGRID_SELF );
            pager = this.urlSecurityResourceManager.pagedQuery( UrlSecurityResource.class, pager, sf );

            this.pageList = pager.getList();
            records = pager.getTotalNumberOfRows();
            total = pager.getTotalNumberOfPages();
            page = pager.getPageNumber();

        }
        catch ( Exception e ) {
            log.error( "GridList Error", e );
        }
        return SUCCESS;
    }
}
